<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png"
	href="img/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>修改新闻</title>

<meta
	content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'
	name='viewport' />
<meta name="viewport" content="width=device-width" />


<!-- Bootstrap core CSS     -->
<link
	href="${pageContext.request.contextPath}/css/bootstrap.min.css"
	rel="stylesheet" />

<!-- Animation library for notifications   -->
<link
	href="${pageContext.request.contextPath}/css/animate.min.css"
	rel="stylesheet" />

<!--  Light Bootstrap Table core CSS    -->
<link
	href="${pageContext.request.contextPath}/css/light-bootstrap-dashboard.css"
	rel="stylesheet" />


<!--  CSS for Demo Purpose, don't include it in your project     -->
<link
	href="${pageContext.request.contextPath}/css/demo.css"
	rel="stylesheet" />


<!--     Fonts and icons     -->
<style type="text/css">
.new-contentarea {
	width: 100%;
	overflow: hidden;
	margin: 0 auto;
	position: relative;
}

.new-contentarea label {
	width: 100%;
	height: 100%;
	display: block;
}

.new-contentarea input[type=file] {
	width: 188px;
	height: 60px;
	background: #333;
	margin: 0 auto;
	position: absolute;
	right: 50%;
	margin-right: -94px;
	top: 0;
	right /*\**/: 0px\9;
	margin-right /*\**/: 0px\9;
	width /*\**/: 10px\9;
	opacity: 0;
	filter: alpha(opacity = 0);
	z-index: 2;
}

a.upload-img {
	width: 165px;
	display: inline-block;
	margin-bottom: 10px;
	height: 57px;
	line-height: 57px;
	font-size: 20px;
	color: #FFFFFF;
	background-color: #f38e81;
	border-radius: 3px;
	text-decoration: none;
	cursor: pointer;
}

a.upload-img:hover {
	background-color: #ec7e70;
}

.tc {
	text-align: center;
}
</style>
<link
	href="${pageContext.request.contextPath}/css/pe-icon-7-stroke.css"
	rel="stylesheet" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/XMLHttpRequest.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.10.2.js"></script>
<script type="text/javascript">
    $(function() {
        $("#ssb").click(function() {
            editor.updateElement();
            //将上传内容部分先将&nbsp用""替换;然后用""替换" "然后用""替换"\n"最后为<p></p>
            var content = $("#content").val();
            var re = new RegExp("&nbsp;", "g");
            var content_flag = content.replace(re, "");
            re = new RegExp(" ", "g");
            content_flag = content_flag.replace(re, "");
            re = new RegExp("\n", "g");
            content_flag = content_flag.replace(re, "");

            var title = $("[name='title']").val();
            var csid = $("[name='csid']").val();
            var flag = true;
            if (title == null || title.trim() == "") {
                 alert("请填写标题");
                flag=false;
            }
            if(csid==-1){
                alert("请选择新闻类目")
            }
            if (content == "" || content_flag == "<p></p>") {
                alert("请填写内容");
                flag=false;
            }
            if(flag){
                $("#form").submit();
            }
        });
    });
    </script>



</head>
<body>

	<div class="wrapper">




        <!--左侧导航栏-->
        <%@include file="./include/left.jsp"%>


		<div class="main-panel">

       <%@include file="./include/nav.jsp"%>



			<div class="content">
				<div class="container-fluid">
                        <div class="row">
                            <div class="col-md-8" style="width: 800px">
                                <div class="card">
                                    <div class="header">
                                        <h4 class="title">新闻修改</h4>
                                    </div>
                                    <div class="content">
                                        <form action="${pageContext.request.contextPath}/news/updateNews.html" method="post" id="form">
                                        <div class="col-md-8">
                                            <div class="form-group" >
                                                <label>新闻类别</label>
                                                <select  class="form-control" name="csid">
                                                    <option value="-1">请选择类别</option>
                                                    <c:forEach items="${categorySeconds}" var="cs">
                                                        <option ${cs.id==newsExt.csid?"selected":""} value="${cs.id}">${cs.csname}</option>
                                                    </c:forEach>
                                                 </select>
                                            </div>
                                        </div>
                                        <input type="hidden" name="pageNow" value="${param.pageNow}"/>
                                        <input type="hidden" name="selTitle" value="${param.title}"/>
                                        <input type="hidden" name="selCsid" value="${param.csid}"/>
                                        <input type="hidden" name="id" value="${param.id}"/>
										<div class="row">
											<div class="col-md-12">
												<div class="form-group">
													<label>标题</label> <input type="text" name="title"
														id="title" class="form-control" placeholder="新闻标题" value="${newsExt.title}">
												</div>
											</div>
										</div>

										<div class="row">
											<div class="col-md-12">
												<div class="form-group">
													<label>内容</label>
													<textarea rows="15" name="content" id="content"
														class="form-control" placeholder="新闻正文....">
                                                        ${newsExt.content}
                                                    </textarea>
												</div>
											</div>
										</div>

										<button type="button" id="ssb"
											class="btn btn-info btn-fill pull-right">修改</button>
										<div class="clearfix"></div>
									</form>
								</div>
							</div>
						</div>



					</div>
				</div>
			</div>




<%@include file="./include/footer.jsp"%>
		</div>
	</div>


</body>

<!--   Core JS Files   -->
<script
	src="${pageContext.request.contextPath}/js/jquery-1.10.2.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/js/bootstrap.min.js"
	type="text/javascript"></script>

<!--  Checkbox, Radio & Switch Plugins -->
<script
	src="${pageContext.request.contextPath}/js/bootstrap-checkbox-radio-switch.js"></script>

<!--  Charts Plugin -->
<script
	src="${pageContext.request.contextPath}/js/chartist.min.js"></script>

<!--  Notifications Plugin    -->
<script
	src="${pageContext.request.contextPath}/js/bootstrap-notify.js"></script>


<!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
<script
	src="${pageContext.request.contextPath}/js/light-bootstrap-dashboard.js"></script>

<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
<script
	src="${pageContext.request.contextPath}/js/demo.js"></script>
<!-- 富文本编辑器 -->
<script type="text/javascript"
        src="${pageContext.request.contextPath }/ckeditor4.4/ckeditor.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath }/ckfinder2.3.1/ckfinder.js"></script>
<script type="text/javascript">
    var editor = null;
    window.onload = function() {
        editor = CKEDITOR.replace('content'); //参数‘content’是textarea元素的name属性值，而非id属性值
        CKFinder.setupCKEditor(editor,
            '${pageContext.request.contextPath }/ckfinder2.3.1/');
    };
</script>
</html>